#include <Mouse.h>

int xPin = 1;
int yPin = 2;
int zPin = 3;

int x=0;
int y=0;
int z=0;

int xDelta =0;
int yDelta =0;
int zDelta =0;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Mouse.begin();
}


int yBegin=0;
int yUp =0;
int yDown= 0;
void loop() {
  yBegin = analogRead(yPin);
  Serial.println(y);
  delay(100);
  yDelta = analogRead(yPin) -yBegin;
  yUp = analogRead(yPin);

  if(yDelta > 80){//go right
    delay(400);
    yDelta = analogRead(yPin) -yUp ;
    if(yDelta < -30){
      //right click
      Mouse.click(MOUSE_RIGHT);
      Serial.println("MOUSE_RIGHT");
      
      //y = analogRead(yPin);
      delay(200);
    }
  }else if(yDelta < -80){//go left
    delay(400);
    yDelta = analogRead(yPin) -yDown ;
    if(yDelta > 30){
      //left click
      Mouse.click(MOUSE_LEFT);
      Serial.println("MOUSE_LEFT");

      //y = analogRead(yPin);
      delay(200);
    }
  }

  y = analogRead(yPin);
  
}
